import {Injectable} from "@angular/core";
import {Process} from "./domains";
import {HttpHelper} from "./HttpHelper";

@Injectable()
export class ProcessService{
    constructor(private helper:HttpHelper){

    }
    processes(page?,size?):Promise<Process[]>{
        let url = "process";
        if (page && size) {
            url = url + `/?page=${page}&size=${size}`;
        }
        return this.helper.getJson<Process[]>(url);
    }

    allProcesses():Promise<Process[]>{
        let url = "process/?all=true";
        return this.helper.getJson<Process[]>(url);
    }

    addProcess(name:string){
        let process=new Process();
        process.processName=name;
        return this.helper.postToBoolean("process",process);
    }
}